You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
stephanmeesters
changed the title
fix(particlesys): Add or optimize null-checks to createParticleSystem calls
refactor(particlesys): Add or optimize null-checks to createParticleSystem calls
May 17, 2026
This PR simplifies particle system creation guards across ~20 files by removing redundant template null-checks that preceded createParticleSystem calls. The refactoring is valid because ParticleSystemManager::createParticleSystem already has an explicit early-exit guard (if (sysTemplate == nullptr) return nullptr) — confirmed at line 3057-3059 of Core/GameEngine/Source/GameClient/System/ParticleSys.cpp — so checking the returned ParticleSystem* pointer is sufficient.
Null-check consolidation: Replaces two-level guards (if (template) { system = create(); if (system) { ... } }) with a single if (system) guard, eliminating ~3–5 lines of boilerplate per call site across both Generals/ and GeneralsMD/ directories.
createSlaveSystem in ParticleSys.cpp: Removes the if (m_slaveTemplate) guard before calling createParticleSystem, relying on the same null-safe invariant inside the manager.
BeaconClientUpdate.cpp: Collapses the failsafe template null-check into the system-return check — the thread on this file has already flagged it for closer review.
Confidence Score: 5/5
Safe to merge — the refactoring is mechanically correct across all 22 files because createParticleSystem already contains an explicit null-template early return.
The entire PR rests on the invariant that createParticleSystem(nullptr) returns nullptr, which is confirmed in the manager implementation. Every call site that previously guarded with if (template) now calls createParticleSystem unconditionally and checks the returned pointer, producing identical runtime behavior. The BeaconClientUpdate.cpp change has a known subtlety discussed in the thread (senior dev recommends revert), but it does not introduce a crash or data corruption.
BeaconClientUpdate.cpp — its failsafe else branch is now triggered by any null return from createParticleSystem rather than only a missing template name, which the thread has already flagged for review.
Removes template null-guard in createSlaveSystem and moves createParticleSystem call before the sys null-check in update; both are safe given the manager's own null-template early return.
Removes outer parentTemp null-guard before createParticleSystem; safe because the manager returns null for null templates and parentSystem is still checked before use.
Removes outer IRGridParticleSysTmpl guard (unlike GeneralsMD which retains it) and collapses inner double-check; behavior is equivalent in both approaches.
Removes template guard and collapses system null-check; logic is correct, though the replacement block introduces slightly inconsistent indentation relative to surrounding code.
Removes attachParticleSystem template guard; the particle system attachment and bone positioning logic is correctly preserved under the single sys null-check.
xezon
changed the title
refactor(particlesys): Add or optimize null-checks to createParticleSystem calls
fix(particlesys): Add or simplify null-checks to createParticleSystem calls
May 18, 2026
xezon
added
Minor
Severity: Minor < Major < Critical < Blocker
Gen
Relates to Generals
ZH
Relates to Zero Hour
Refactor
Edits the code with insignificant behavior changes, is never user facing
Fix
Is fixing something, but is not user facing
labels
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FixIs fixing something, but is not user facingGenRelates to GeneralsMinorSeverity: Minor < Major < Critical < BlockerRefactorEdits the code with insignificant behavior changes, is never user facingZHRelates to Zero Hour
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
createParticleSystemis null checkedTodo